import vueRouter from 'vue-router'
import Vue from 'vue'
Vue.use(vueRouter)

// 防止在当前页面跳转当前页面报错（自己跳自己）
let originPush = vueRouter.prototype.push
let originReplace = vueRouter.prototype.replace
// 重写push方法，解决多次点击搜索报错问题
vueRouter.prototype.push = function (location, resolve, reject) {
    if (resolve && reject) {
        originPush.call(this, location, resolve, reject)
    } else {
        originPush.call(this, location, () => { }, () => { })
    }
}
// 重写replace方法
vueRouter.prototype.replace = function (location, resolve, reject) {
    if (resolve && reject) {
        originReplace.call(this, location, resolve, reject)
    } else {
        originReplace.call(this, location, () => { }, () => { })
    }
}

// 引入路由组件模块
import routes from './routes.js'
export default new vueRouter({
  routes
})